package com.demo.rabbitmq.config;

import java.util.HashMap;
import java.util.Map;

public enum DeadQueueEnum {

    DEAD_BUSINESS_QUEUE("dead_business_queue", DeadExchangeEnum.DEAD_BUSINESS_EXCHANGE, DeadRoutingKeyEnum.DEAD_BUSINESS_QUEUE_ROUTING_KEY, DeadExchangeEnum.DEAD_EXCHANGE, DeadRoutingKeyEnum.DEAD_QUEUE_ROUTING_KEY),
    DEAD_QUEUE("dead_queue", DeadExchangeEnum.DEAD_EXCHANGE,  DeadRoutingKeyEnum.DEAD_QUEUE_ROUTING_KEY, null, null),
    ;

    private String queueName;
    private DeadExchangeEnum businessExchangeEnum;
    private DeadRoutingKeyEnum businessRoutingKeyEnum;
    private DeadExchangeEnum deadExchangeEnum;
    private DeadRoutingKeyEnum deadRoutingKeyEnum;
    private
    DeadQueueEnum(String queueName, DeadExchangeEnum businessExchangeEnum, DeadRoutingKeyEnum businessRoutingKeyEnum, DeadExchangeEnum deadExchangeEnum, DeadRoutingKeyEnum deadRoutingKeyEnum) {
        this.queueName = queueName;
        this.businessExchangeEnum = businessExchangeEnum;
        this.businessRoutingKeyEnum = businessRoutingKeyEnum;
        this.deadExchangeEnum = deadExchangeEnum;
        this.deadRoutingKeyEnum = deadRoutingKeyEnum;
    }

    public Map<String, Object> arguments() {
        Map<String, Object> map = new HashMap<>();
        if (deadExchangeEnum != null) {
            // x-dead-letter-exchange    这里声明当前队列绑定的死信交换机
            map.put("x-dead-letter-exchange", deadExchangeEnum.getExchangeName());
        }
        if (deadRoutingKeyEnum != null) {
            // x-dead-letter-routing-key  这里声明当前队列的死信路由key
            map.put("x-dead-letter-routing-key", deadRoutingKeyEnum.getRoutingKeyName());
        }
        return map;
    }

    public String getQueueName() {
        return queueName;
    }

    public DeadExchangeEnum getBusinessExchangeEnum() {
        return businessExchangeEnum;
    }

    public String getRoutingKeyName() {
        return this.businessRoutingKeyEnum.getRoutingKeyName();
    }
}
